package com.ksd.pug.clound.controller;

import com.ksd.pug.clound.pojo.SysUser;
import com.ksd.pug.clound.service.UserServiceFuture;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;

/**
 * @author 飞哥
 * @Title: 学相伴出品
 * @Description: 飞哥B站地址：https://space.bilibili.com/490711252
 * 记得关注和三连哦！
 * @Description: 我们有一个学习网站：https://www.kuangstudy.com
 * @date 2022/2/25 15:47
 */
@RestController
@RequestMapping("/consumer")
@Slf4j
public class UserController {

    @Autowired
    private UserServiceFuture userServiceFuture;

    @GetMapping("/user/{id}")
    public SysUser findUsers(@PathVariable("id") Long id) throws ExecutionException, InterruptedException {
        Future<SysUser> sysuser1 = userServiceFuture.getSysuser(1L);
        Future<SysUser> sysuser2 = userServiceFuture.getSysuser(2L);
        Future<SysUser> sysuser3 = userServiceFuture.getSysuser(3L);
        Future<SysUser> sysuser4 = userServiceFuture.getSysuser(4L);
        return sysuser1.get();
    }

}
